//
//  IOAResponse.h
//  IOAMall
//
//  Created by Mac on 2018/3/5.
//  Copyright © 2018年 Mac. All rights reserved.
//

#import <Foundation/Foundation.h>

// 网络请求错误码说明
typedef NS_ENUM(NSInteger, ResponseStatusType) {
    ResponseStatusTypeNoNetwork = -1, // 没有网络
    ResponseStatusTypeRequestSuccess = 0, // 请求成功
    ResponseStatusTypeExpiryToken = 1002, // 登录过期
    ResponseStatusTypeNonExistent = 1003, // xx不存在
    ResponseStatusTypeRequestError = 1004, // 请求错误
    ResponseStatusTypeRequestFail = 1005, // 请求失败
    ResponseStatusTypeNoData = 1006, // 暂无数据
    ResponseStatusTypeUnauthorized = 1007 // 未实名认证
};

@class IOARequest;

@interface IOAResponse : NSObject

@property (nonatomic, assign) BOOL success; // 是否请求成功 根据业务逻辑判断
@property (nonatomic, assign) ResponseStatusType responseStatusType;
@property (nonatomic, assign) NSInteger serverResponseStatusCode; // 服务端返回的status code
@property (nonatomic, assign) NSInteger requestResponseStatusCode; // 接口请求返回的status code

@property (nonatomic, strong) id responseObject; // 返回请求数据

@property (nonatomic, copy) NSString *responseMessage; // 提示信息

+ (IOAResponse *)responseWithRequest:(IOARequest *)request;

- (void)updateStatusCodesWithRequest:(IOARequest *)request;

// 是否需要提示
- (BOOL)alertOrNot;

// 是否没有有网络
- (BOOL)isNoNetwork;

// 是否token失效
- (BOOL)isExpiryToken;

// 后台服务错误
- (BOOL)isRequestServerError;

// 服务器错误
- (BOOL)isServerServiceError;

// 该目标已存在
- (BOOL)isTargetExist;

@end
